C/C++中double与byte数组互转的方法

您所在的位置:网站首页 qt double转char数组 C/C++中double与byte数组互转的方法

C/C++中double与byte数组互转的方法

2023-03-26 18:55| 来源: 网络整理| 查看: 265

C/C++中double与byte数组互转的方法 发布时间:2021-07-20 17:45:49 来源:亿速云 阅读:2057 作者:chen 栏目:大数据

这篇文章主要介绍“C/C++中double与byte数组互转的方法”,在日常操作中,相信很多人在C/C++中double与byte数组互转的方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”C/C++中double与byte数组互转的方法”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

本文包含了C/C++中byte(unsigned char)类型与double数组互转的方法,参见本文的最后两个方法,亲测可行。

#include  #include  #include  typedef unsigned char byte; typedef struct {     int precession;     double value; }ConstantValue; byte int2Byte(int intVal); void double2bytes(double data, byte* bytes); double bytes2double(byte bytes[]); std::vector convert2Byte(ConstantValue cv); using namespace std; /** double convert to bytes refers to struct body attribute */ int main(){     ConstantValue cv1, cv2;     cv1.precession = 10;     cv1.value = 36.32598;     cv2.precession = 15;     cv2.value = 271.15801;     vector cv1Byte = convert2Byte(cv1);     vector cv2Byte = convert2Byte(cv2);      for(int i = 0; i 


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3